home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Views / Canvas / Canvas.h < prev    next >
Text File  |  2000-06-23  |  3KB  |  97 lines

  1. // Canvas.h
  2.  
  3. #ifndef Canvas_h
  4. #define Canvas_h
  5.  
  6. #ifndef PortMap_h
  7. #include "PortMap.h"
  8. #endif
  9. #ifndef RegionObject_h
  10. #include "RegionObject.h"
  11. #endif
  12.  
  13. class GrafPortObject;
  14. class WindowObject;
  15.  
  16. class Canvas: private PortMap
  17.   {
  18.     private:
  19.         GrafPortObject *port;
  20.         WindowObject *window;
  21.         RegionObject clip;
  22.         
  23.         PortMap& Map()                                { return *this; }
  24.         
  25.         static RegionObject& TemporaryRegion();
  26.  
  27.         RegionObject& ClippedRegion( Rectangle ) const;
  28.         RegionObject& ClippedRegion( const RegionObject& ) const;
  29.         
  30.     public:
  31.         Canvas();
  32.         explicit Canvas( GrafPortObject& );
  33.         explicit Canvas( WindowObject& );
  34.         explicit Canvas( const Canvas& source );
  35.         
  36.         void operator=( WindowObject& );
  37.         void operator=( GrafPortObject& );
  38.  
  39.         bool operator==( const Canvas& ) const;
  40.         bool operator!=( const Canvas& c ) const        { return !operator==(c); }
  41.         
  42.         void Clear()                                { port = 0; window = 0; }
  43.         
  44.         bool HasPort() const                        { return port != 0; }
  45.         GrafPortObject& Port() const            { Assert( HasPort() ); return *port; }
  46.  
  47.         bool HasWindow() const                    { return window != 0; }
  48.         WindowObject& Window() const            { Assert( HasWindow() ); return *window; }
  49.  
  50.         const RegionObject& Clip() const        { Assert( HasPort() ); return clip; }
  51.         bool Visible() const                        { return HasPort() && !clip.IsEmpty(); }
  52.  
  53.         const PortMap& Map() const                { return *this; }
  54.         
  55.         PortMap::OffScreen;
  56.         PortMap::OnScreen;
  57.         PortMap::HorizontalToScreen;
  58.         PortMap::VerticalToScreen;
  59.         PortMap::HorizontalFromScreen;
  60.         PortMap::VerticalFromScreen;
  61.         PortMap::ToScreen;
  62.         PortMap::FromScreen;
  63.  
  64.         void RestrictOnScreen( Rectangle r );
  65.         void RestrictOnScreen( const RegionObject& );
  66.         void RestrictOffScreen( Rectangle32 );
  67.         void RestrictToValid();
  68.         void RestrictToInvalid();
  69.         
  70.         void Submap( Rectangle32 );
  71.         void SliceHorizontally( Range32 verticalRange );
  72.         void SliceVertically( Range32 horizontalRange );
  73.         
  74.         PortMap::Scroll;
  75.         
  76.         void ObstructOnScreen( Rectangle );
  77.         void ObstructOnScreen( const RegionObject& );
  78.         void ObstructOffScreen( Rectangle32 );
  79.  
  80.         void GetValidRegion( RegionObject& ) const;
  81.         void GetInvalidRegion( RegionObject& ) const;
  82.         
  83.         void Validate() const;
  84.         void ValidateOnScreen( Rectangle ) const;
  85.         void ValidateOnScreen( const RegionObject& ) const;
  86.         void ValidateOffScreen( Rectangle32 ) const;
  87.         
  88.         void Invalidate() const;
  89.         void InvalidateOnScreen( Rectangle ) const;
  90.         void InvalidateOnScreen( const RegionObject& ) const;
  91.         void InvalidateOffScreen( Rectangle32 ) const;
  92.   };
  93.  
  94. void Copy( const Canvas& source, const Canvas& destination );
  95.  
  96. #endif
  97.